package com.atiguigu.rabbitmq.two;

import com.atiguigu.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/*
* 这是一个工作线程（类似one.Consumer）
* */
public class Worker01 {
    //队列名称
    public static  final String QUEUE_NAME="hello";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMqUtils.getChannel();
        //消息的接收
        DeliverCallback deliverCallback=(consumerTag, message) ->{
            System.out.println("接收到的消息："+new String(message.getBody()));
        };
        CancelCallback callback=consumerTag->{
            System.out.println(consumerTag+"消费者取消消费接口回调逻辑");
        };
        System.out.println("C2等待接收消息。。。");
        channel.basicConsume(QUEUE_NAME,true,deliverCallback,callback);

    }
}
